package com.cande.loki.exercise.algorithm;

import java.util.Arrays;

/**
 * @BelongsProject: loki
 * @BelongsPackage: com.cande.loki.exercise.algorithm
 * @Author: WANGAOFEI
 * @CreateTime: 2023-10-20  17:09
 * @Description: TODO
 * @Version: 1.0
 */
public class MergeArraySort {
    public static void main(String[] args) {
        int[] arr = {1,2,3,0,0,0};
        int[] arr1 = {2,4,9};
        merge1(arr,3,arr1,3);
        System.out.println(Arrays.toString(arr));
    }
    public static void merge1(int[] arr1,int m ,int[]arr2,int n){
        int i = m-1;
        int j = n-1;
        int k = arr1.length -1 ;
        while (i>=0 && j >=0){
            arr1[k--] = arr1[i] > arr2[j] ? arr1[i--] : arr2[j--];
        }
        while (j >=0){
            arr1[k--] = arr2[j--];
        }

    }
}
